package com.visikard.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;

import com.visikard.item.GeoSearchItem;

public class SearchAddressResponse extends BaseResponse {
	private List<GeoSearchItem> listGeoSearchItems;

	public List<GeoSearchItem> getListGeoSearchItems() {
		return listGeoSearchItems;
	}

	public void setListGeoSearchItems(List<GeoSearchItem> listGeoSearchItems) {
		this.listGeoSearchItems = listGeoSearchItems;
	}

	@Override
	public void extractDataFromServer(String response) throws JSONException {
		super.extractDataFromServer(response);

		// response OK
		if (errorCode == SUCCESS) {
			JSONArray jArray = getDataJArray(response);
			List<GeoSearchItem> listResult = new ArrayList<GeoSearchItem>();
			for (int i = 0; i < jArray.length(); i++) {
				listResult.add(new GeoSearchItem(jArray.getJSONObject(i)));
			}
			listGeoSearchItems = listResult;
		}
	}

}
